<?php 
        $month = substr($calendar,-2);
        $year  = substr($calendar,0,4);
        $x     = $offset+1;
      foreach ($journey as $key) {
        echo "<tr>";
        echo "<td align='center'>".$x++.'</td>';
        // echo '<td><a href="'. base_url().'index.php/outlet/view/'.$this->enc->fogit($key["partner_id"]).'">'.$key['partner_id'].'</a></td>';
        echo "<td>".$key['partner_id']."</td>";
        echo "<td>".$key['territory_name']."</td>";

        for ($i=1; $i <= cal_days_in_month(CAL_GREGORIAN, $month, $year) ; $i++) {
          $date = intval($year.$month.substr("00" .$i, -2));

          if (date("W", strtotime($date)) == date('W') ) 
            { $current = 'current-week '.date("W", strtotime($date)).' '.$date ; }
          else if (date("W", strtotime($date)) < date('W') )
            { $current = 'past '.date("W", strtotime($date)).' '.$date; }
          else 
            { $current =  date("W", strtotime($date)).' '.$date;}
          if (date("l", strtotime($date)) == 'Sunday')
            { $current = 'sunday'; }

          // Determine holidays
          foreach ($holidays as $freeday) {
            if(intval($freeday->tanggal) == $date)
              { $current .= ' holidays'; }
          }

          if ($key["d$i"] == 1) {
            if ($date < intval(date('Ymd', time())) )
              { echo '<td class="d'.$i.' '.$current.'"><img src="'.base_url().'file/images/tick-2.png" /></td>'; } 
            else
              { echo '<td class="d'.$i.' '.$current.'"><input type="checkbox" name="journey" class="jc" id="'.$key['partner_id'].'_'.$key['t_id'].'_'.$year.$month.'_d'.$i.'" onchange="simpan(\''.$key['partner_id'].'_'.$key['t_id'].'_'.$year.$month.'_d'.$i.'\')" checked="checked" ></td>'; }
          }
          else if ($date < intval(date('Ymd', time())) )
            { echo '<td class="d'.$i.' '.$current.'"><img src="'.base_url().'file/images/minus-small.png" /> </td>'; }
          else 
            { echo '<td class="d'.$i.' '.$current.'"><input type="checkbox" name="journey" class="jc" id="'.$key['partner_id'].'_'.$key['t_id'].'_'.$year.$month.'_d'.$i.'" onchange="simpan(\''.$key['partner_id'].'_'.$key['t_id'].'_'.$year.$month.'_d'.$i.'\')" ></td>'; }
        }
        echo "</tr>";
      }  
?>